package com.example.cookieandsession.cookie;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created with IntelliJ IDEA.
 * ClassName: DemoController
 * Package: com.example.cookieandsession.controller
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-04-12
 * Time: 21:09
 */

@RestController
@RequestMapping("/user/aaa/bbb")
public class DemoController {

    //获取请求中的Cookie
    @RequestMapping("/bdd")
    public void bdd(HttpServletResponse response, HttpServletRequest request){

        Cookie[] cookies = request.getCookies();
        for (Cookie cookie : cookies) {
            System.out.println(cookie.getName() + "=========" + cookie.getValue());
            //获取到 就可以操作了
            if (cookie.getName().equals("HaDeng")){
                System.out.println("就可以操作了");
            }
        }

    }
}
